package com.dbb

import java.util.List;

class Ctn {
	Product product
	CtnType ctnType
	Integer prs;
	
	Float length;
	Float width;
	Float high;
	//Float cbm;
	Float netWeight;
	Float grossWeight;
	
	
	static hasMany = [colorSizes : ColorSize]
    static constraints = {
    }
	
	public Float getCbm() {
		return (length * high * width) / 1000000;
	}
	
	String toString() {
		return this.product.name + " " + this.ctnType
	}
	
	public static List<Ctn> init() {
		List<Ctn> ctns = new ArrayList<Ctn>()
		List<Product> products = Product.init()
		ctns.add(new Ctn(products.get(0), CtnType.A, 30, 78f, 46f, 60f, 10f, 12f))
		ctns.add(new Ctn(products.get(0), CtnType.B, 30, 78f, 46f, 60f, 10f, 12f))
		ctns.add(new Ctn(products.get(1), CtnType.A, 30, 65f, 60f, 32f, 10.5f, 12f))
		ctns.add(new Ctn(products.get(1), CtnType.B, 30, 65f, 60f, 32f, 10.5f, 12f))
		ctns.add(new Ctn(products.get(2), CtnType.A, 30, 64f, 62f, 30.5f, 10.5f, 12f))
		ctns.add(new Ctn(products.get(2), CtnType.B, 30, 64f, 62f, 30.5f, 10.5f, 12f))
		ctns.add(new Ctn(products.get(3), CtnType.A, 30, 65f, 60f, 32f, 7.5f, 9f))
		ctns.add(new Ctn(products.get(3), CtnType.B, 30, 65f, 60f, 32f, 7.5f, 9f))
		ctns.add(new Ctn(products.get(4), CtnType.A, 30, 80f, 59f, 31f, 11f, 12.5f))
		ctns.add(new Ctn(products.get(4), CtnType.B, 30, 80f, 59f, 31f, 11f, 12.5f))
		return ctns;
	}
	
	
}
